import * as THREE from 'three'
import { Tween as TWEEN,Easing } from 'three/examples/jsm/libs/tween.module';
import { Mesh,Vector3 } from 'three';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
export function controlsMoveCoordin(controls:OrbitControls,position:Vector3,target:Vector3) {
    let tween = new TWEEN({
        px: controls.object.position.x, // 起始相机位置x
        py: controls.object.position.y, // 起始相机位置y
        pz: controls.object.position.z, // 起始相机位置z
        tx: controls.target.x, // 控制点的中心点x 起始目标位置x
        ty: controls.target.y, // 控制点的中心点y 起始目标位置y
        tz: controls.target.z // 控制点的中心点z 起始目标位置z
    })
    tween.to({
        px: position.x,
        py: position.y,
        pz: position.z,
        tx: target.x,
        ty: target.y,
        tz: target.z
    }, 1000)
    tween.onUpdate( function( pos:any ) {
        controls.object.position.x = pos.px;
        controls.object.position.y = pos.py;
        controls.object.position.z = pos.pz;
        controls.target.x = pos.tx;
        controls.target.y = pos.ty;
        controls.target.z = pos.tz;
    })
    tween.easing( Easing.Cubic.InOut );
    tween.start();
}